package cn.tedu.rabbitmqboot.m3;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 消费者自动启动，注册成为消费者，自动监听队列中的消息
 * 不需要手动调用
 */
@Component
public class Consumer {
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue,//由服务器自动命名队列，false,true,true
            exchange = @Exchange(name = "logs",declare = "false")//不重复定义这个交换机
    ))
    public void recieve1(String msg){
        System.out.println("消费者1收到："+msg);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue,//由服务器自动命名队列，false,true,true
            exchange = @Exchange(name = "logs",declare = "false")//不重复定义这个交换机
    ))
    public void recieve2(String msg){
        System.out.println("消费者2收到："+msg);
    }


}
